<template>
  <HomePanel title="最新专题">
    <template #right>
      <XtxMore></XtxMore>
    </template>

    <template #default>
      <div ref="target" class="special-list">
        <div v-for="item in list" :key="item.id" class="special-item">
          <router-link to="/">
            <img v-lazy="item.cover" alt/>
            <div class="meta">
              <div class="title">
                <p class="top ellipsis">{{ item.title }}</p>
                <p class="sub ellipsis">{{ item.summary }}</p>
              </div>
              <span class="price">&yen;{{ item.lowestPrice }}起</span>
            </div>
          </router-link>
          <div class="foot">
            <span class="like"><i class="iconfont icon-hart1"></i>{{ item.collectNum }}</span>
            <span class="view"><i class="iconfont icon-see"></i>{{ item.viewNum }}</span>
            <span class="relay"><i class="iconfont icon-message"></i>{{ item.replyNum }}</span>
          </div>
        </div>
      </div>
    </template>
  </HomePanel>
</template>

<script>
import HomePanel from '@/components/home/HomePanel'
import XtxMore from '@/components/library/XtxMore'
import API from '@/api/home'
import { useLazyData } from '@/hooks'

export default {
  name: 'HomeSpecial',
  components: {
    XtxMore,
    HomePanel
  },
  setup() {
    const {
      target,
      result: list
    } = useLazyData(API.getLatestSpecial)

    return {
      target,
      list
    }
  }
}
</script>

<style lang="less" scoped>
.home-panel {
  .special-list {
    display: flex;
    justify-content: space-between;
    height: 380px;
    padding-bottom: 20px;

    .special-item {
      width: 404px;
      background-color: #fff;
      // 动画效果
      .hoverShadow();

      a {
        display: block;
        width: 404px;
        height: 288px;
        // 构成子绝父相
        position: relative;

        img {
          width: 100%;
          height: 100%;
          //background-size: cover;
          object-fit: cover;
        }

        .meta {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 288px;
          background-image: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent 50%);

          .title {
            position: absolute;
            left: 0;
            bottom: 0;
            padding-left: 16px;
            width: 70%;
            height: 70px;

            .top {
              color: #fff;
              font-size: 22px;
            }

            .sub {
              text-indent: 10px;
              font-size: 19px;
              color: #999;
            }
          }

          .price {
            position: absolute;
            bottom: 25px;
            right: 16px;
            padding: 4px 8px;

            font-size: 17px;
            line-height: 1;
            color: @priceColor;
            border-radius: 2px;
            background-color: #fff;
          }
        }
      }

      .foot {
        height: 72px;
        line-height: 72px;
        padding: 0 20px;
        font-size: 16px;

        i {
          display: inline-block;
          width: 15px;
          height: 14px;
          margin-right: 5px;
          color: #999;
        }

        .like, view {
          float: left;
          margin-right: 20px;
          vertical-align: middle;
        }

        .relay {
          float: right;
          vertical-align: middle;
        }
      }
    }
  }
}


</style>
